<template>
  <div class='connector-app message-node' @click="open">
    <div class="header">
      {{$t('common.base.messageNotification')}}
      <i class="iconfont icon-xiaoxi" />
    </div>
    <div class="app-info-empty" v-if="app.data.side == 0 || app.data.side == 1">
      <span class="message-title"> {{ app.data.side ? $t('common.connector.trigger.notificationType.customer') : $t('common.connector.trigger.notificationType.inside') }}</span>
      <i class="iconfont icon-right1" />
    </div>
    <div class="app-info-empty" v-else>
      {{ $t('common.connector.trigger.notificationType.selectType') }}
      <i class="iconfont icon-right1" />
    </div>
  </div>
</template>
<script>

export default {
  name:'message',
  props:{
    nodeConfig:{
      type:Object,
      default:()=>({})
    },
    moduleList:{
      type:Array,
      default:()=>([])
    },
    parent:{
      type:Object,
      default:()=>({})
    }
  },
  watch:{
    nodeConfig:{
      handler(newVal){
        this.app = newVal
      },
      deep:true,
      immediate:true
    },
    parentApp:{
      // 切换发起应用时候 将消息配置清空
      handler(newVal) {
        if(this.app.isEdit){
          this.app.isEdit = false
        }else{
          // this.app.data = {}
          // this.app.id = ''
        }
        this.$emit('update:nodeConfig', this.app)
      },
      deep: true,
      immediate: true
    }
  },
  computed:{
    parentApp() {
      return this.parent.getParent().isTrigger
        ? this.parent.getParent().getParent().data
        : this.parent.getParent().data;
    },
  },
  data(){
    return {
      app:this.nodeConfig,
      treeDefaultProps:{
        children: 'children',
        label: 'name',
        key: 'bizTypeId',
      }
    }
  },
  methods:{
    handleTreeSelect(val){
      let data = {
        bizActionName:'',
        bizActionCode:'',
      }
      if(val){
        let {bizActionName, bizActionCode} = val
        data = {bizActionName, bizActionCode}
      }
      this.app.data = data
      this.$emit('update:nodeConfig', this.app)
    },
    open(){
      this.$emit('open')
    }
  },
  components:{
  }
}

</script>